< previous page page_371 next page >

Page 371
8694cbadb9b1ef7075903f6f95fc1db2.gif
 7:
 8:     Set dbTable = OpenDatabase(App.Path & \AddressBook.mdb)
 9: Open table
10:     Set dbquery = dbTable.OpenRecordset(select * from reports order by_
11: [ReportFileName], dbOpenDynaset)
12:     dbquery.MoveLast
13:     Total_Reports = dbquery.RecordCount
14:     ReDim Report_Names(Total_Reports)
15:     dbquery.MoveFirst
16: Loop until there are no more reports to add
17:     For I = 1 To Total_Reports
18:         Set the Report Names
19:         lstReportName.AddItem dbquery.Fields(1)
20:         Report_Names(lstReportName.NewIndex) = dbquery.Fields(0)
21:         dbquery.MoveNext
22:     Next I
23:     dbquery.Close
24:     dbTable.Close
25: End Sub

This section of code sets the report display option to Display and also sets the printer options visible property to False. When the user changes the display type by using the option buttons, the caption of the cmdReport button is changed from Display to Print. The code shown in Listing 13.3 is used to perform this action when the user clicks either of the option buttons.
LISTING 13.3. RPTMGR03.TXTTHECLICKROUTINE FOR THE OPTION BUTTONS ON THE FORM.

8694cbadb9b1ef7075903f6f95fc1db2.gif
1: Private Sub optDisplay_Click(Index As Integer)
2:     If Index = 0 Then
3:         cmdReport.Caption = Display
4:         cmdPrtSetup.Visible = False
5:     Else
6:         cmdReport.Caption = Print
7:         cmdPrtSetup.Visible = True
8:     End If
9: End Sub

It also sets the WindowMinButton property of the Crystal Reports control to false, so that the user cannot minimize the report display. In addition, the ListItem property of the list box is used to hold the report's filename for later use. In the Load routine, you see a loop that initializes the ListBox control. The data that is placed in the list box is read from a database table that contains the following information:

 
< previous page page_371 next page >

If you like this book, buy it!